//
//  WBTabBarViewController.swift
//  YUANSHI
//
//  Created by pro on 2019/12/7.
//  Copyright © 2019 wangbin. All rights reserved.


import UIKit

class WBTabBarViewController: UITabBarController {

    
    var navigation = UINavigationController()
    var popDelegate: UIGestureRecognizerDelegate?
    override func viewDidLoad() {
        super.viewDidLoad()
    
        setUI()
        
       
    }
    
    func setUI() {
        
        tabBar.tintColor = UIColor(red: 38/225, green: 168/225, blue: 254/225, alpha: 1) //tabbar 字体颜色
        tabBar.barTintColor = UIColor.white //tabbar 背景颜色
        
        self.addChilVc(chilVc: HomeViewController(), chilVcTitle: "首页", imageName: "bx_tabbar_business", selectImageName: "bx_tabbar_business_selected", itmeTag: 1)
        self.addChilVc(chilVc: QuotationViewController(), chilVcTitle: "行情", imageName: "bx_tabbar_market", selectImageName: "bx_tabbar_market_selected", itmeTag: 2)
        self.addChilVc(chilVc: TransactionViewController(), chilVcTitle: "交易", imageName: "bx_tabbar_opsition", selectImageName: "bx_tabbar_opsition_selected", itmeTag: 3)
        self.addChilVc(chilVc: MineViewController(), chilVcTitle: "我的", imageName: "bx_tabbar_my", selectImageName: "bx_tabbar_my_selected", itmeTag: 4)
    }
    
    private func addChilVc(chilVc : UIViewController , chilVcTitle : String , imageName : String , selectImageName : String , itmeTag : Int){
        
        navigation = WBNavigationViewController(rootViewController: chilVc)
        navigation.navigationBar.isTranslucent = false
        self.popDelegate = navigation.interactivePopGestureRecognizer?.delegate
        chilVc.tabBarItem.tag = itmeTag
        chilVc.tabBarItem.image = UIImage(named: imageName)?.withRenderingMode(.alwaysOriginal)
        chilVc.tabBarItem.selectedImage = UIImage(named: selectImageName)?.withRenderingMode(.alwaysOriginal)
        chilVc.title = chilVcTitle
        chilVc.tabBarItem.title = chilVcTitle
        self.addChild(navigation)
    }
    
}




